<?php
// +----------------------------------------------------------------------
// | PHP [ JUST YOU ]
// +----------------------------------------------------------------------
// | Copyright (c) 2017~2017 http://www.jyphp.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: FlyingPig <flyingpigfp@163.com>
// +----------------------------------------------------------------------

namespace App\Model\Club;


use App\Model\Base;
use App\Model\Room\CreateRoomRec;
use App\Model\User\ClubMemberInfo;
use App\Model\User\User;
use Illuminate\Support\Facades\Redis;

class Table extends Base
{

    protected $table = 't_club_info';

    protected $with = ['user'];

    protected $withCount = ['club','room'];

    public function user()
    {
        return $this->hasOne(User::class,'id','uid')->select(['id','nick_name','avater_url']);
    }

    public function club()
    {
        return $this->hasMany(ClubMemberInfo::class,'clubid','id');
    }

    public function room()
    {
        return $this->hasMany(CreateRoomRec::class,'clubid','id')->whereIn('status',[1,2]);
    }

}